from setting import setting
from package.connector.redis_db import rdb
from package.connector.sql_db import db
from package.connector.elastic_db import es_db
from model.model import Base


def initialize_table():
    """初始化数据库表信息"""
    # Base.metadata.drop_all(bind=db.engine)
    Base.metadata.create_all(bind=db.engine)


def load_cache():
    """需要加载到redis中的缓存信息"""
    pass


def init():
    """系统初次启动时需要初始化内置数据"""
    initialize_table()


if __name__ == '__main__':
    db.init(url=setting.pg_uri)
    rdb.init(host=setting.redis_host, password=setting.redis_password)
    es_db.init(hosts=f'http://{setting.elasticsearch_host}:{setting.elasticsearch_port}')
    init()
